<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form id="addForm">
    <table class="table table-condensed" border="1" cellspacing="0" cellpadding="0"  >
        <tr>
            <td style="text-align: center;vertical-align: middle">广告分类</td>
            <td>
                <select id="categoryId" name="categoryId">
                    <option th:each="c : ${categoryList}" th:value="${c.id}" th:text="${c.name}"></option>
                </select>
            </td>
        </tr>
        <tr>
            <td style="text-align: center;vertical-align: middle">标题</td>
            <td>
                <input type="text" name="title">
            </td>
        </tr>
        <tr>
            <td style="text-align: center;vertical-align: middle">URL</td>
            <td>
                <input type="text" name="url">
            </td>
        </tr>
        <tr>
            <td style="text-align: center;vertical-align: middle">排序</td>
            <td>
                <input type="text" name="sortOrder">
            </td>
        </tr>
        <tr>
            <td style="text-align: center;vertical-align: middle">广告图片</td>
            <td>
                <input type="text" id="pic" name="pic">
                <input type="file" id="images" name="pic">
            </td>
        </tr>
        <tr>
            <td style="text-align: center;vertical-align: middle">是否有效</td>
            <td>
                <input type="radio" value="1" name="status">有效
                <input type="radio" value="2" name="status">无效
            </td>
        </tr>
    </table>
</form>
</body>
<script>
    $('#images').fileinput({
        language: 'zh',
        uploadUrl:'/fileController/upLoadFile',
        showCaption: true,
        showUpload: true,
        showRemove: true,
        showClose: true,
        layoutTemplates:{
            actionDelete: ''
        },
        browseClass: 'btn btn-primary'
    }).on("fileuploaded",function (e,result,msg){
        if (result.response.code == 10000){
            var url = result.response.data;
            $("#pic").val(url);
        }
    }).on("fileerror",function (){
        alert("上传失败")
    });
</script>
</html>